import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;


@WebServlet("/requestData")
public class AccessDataServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=utf-8");
        PrintWriter  out=resp.getWriter();
        String  usn = req.getParameter("usename");
        //解决乱码
        byte[] data01  = usn.getBytes("ISO8859-1");
        String usnnew = new String(data01,"utf-8");

        String  id = req.getParameter("id");
        String  sex = req.getParameter("sex");
        String major= req.getParameter("major");
        //解决乱码
        byte[] data02  = major.getBytes("ISO8859-1");
        String majornew = new String(data02,"utf-8");

        String jianjie  = req.getParameter("jianjie");
        //解决乱码
        byte[] data03  = jianjie.getBytes("ISO8859-1");
        String jianjienew = new String(data03,"utf-8");

        String sexjudge=("1".equals(sex))?"男":"女";

        out.println("<html>");
        out.println("<body>");
        out.println("<h3>用户名："+usnnew+"</h3>");
        out.println("<h3>学号："+id+"</h3>");
        out.println("<h3>性别："+sexjudge+"</h3>");
        out.println("<h3>专业："+majornew+"</h3>");
        out.println("<h3>个人简介："+jianjienew+"</h3>");
        out.println("</body>");
        out.println("</html>");


    }
}